<%--
  Created by IntelliJ IDEA.
  User: 86151
  Date: 2022/1/8
  Time: 11:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>城市页面</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</head>
<body>
<center>
    <h1>城市分布页面</h1>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>城市编号</th>
            <th>城市名</th>
            <th>人口</th>
            <th>国家名</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${page.list}" var="city">
            <tr>
                <td>${city.cityid}</td>
                <td>${city.cityname}</td>
                <td>${city.citysize}</td>
                <td>${city.country.cname}</td>
                <td><button type="button" class="btn btn-danger" onclick="del(${city.cityid})">删除</button>
                    <button type="button" class="btn btn-info" onclick="edit(${city.cityid})">修改</button>
                    <button type="button" class="btn btn-success" onclick="insert()">添加</button></td>
            </tr>
        </c:forEach>
        </tbody>
        <tfoot>
        <tr>
            <td>
                当前页${page.pageNum}
                <a href="/city/page/1/3">首页</a>
                <a href="/city/page/${page.pageNum-1}/3">上一页</a>
                <a href="/city/page/${page.pageNum+1}/3">下一页</a>
                <a href="/city/page/${page.pages}/3">尾页</a>
            </td>
        </tr>
        </tfoot>
    </table>
</center>
</body>
<script>
    function edit(cityid) {
        location.href = '/city/' + cityid;
    }

    function del(cityid) {
        location.href = '/city/delete/' + cityid;
        /*$(this).parents('tr').remove();*/
    }
    /*$('.btn-danger').on('click',function (){
        $(this).parents('tr').remove()
        var id = $(this).attr('onclick')
        $.ajax({
            id:id
        })
    })*/

    function insert() {
        location.href = '/pages/cit/insert.jsp';
    }
</script>
</html>
